from PyQt5.Qt import *
import sys


"""
1.keyPressEvent  按下键盘
2.keyReleaseEvent 松开键盘
"""
class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("")
        self.resize(600,400)
    def keyPressEvent(self, evt):
        print('按下')
        if evt.key() == Qt.Key_5:
            print(5)
        if evt.key() == Qt.Key_1:
            self.close()
        if evt.modifiers()==Qt.ControlModifier and evt.key() == Qt.Key_Delete:
            print('强制删除')
        if (evt.modifiers()==Qt.ControlModifier or evt.modifiers()==Qt.ShiftModifier) and evt.key() == Qt.Key_C:
            print('复制')
        # print(dir(evt))
    def keyReleaseEvent(self, evt):
        print('松开')
    



if __name__=='__main__':
    app = QApplication(sys.argv)
    w = Window()
    w.show()
    sys.exit(app.exec_())